package com.analyse.stock.controller;

import com.analyse.stock.enums.Sentiment;
import com.analyse.stock.form.PickStockQueryForm;
import com.analyse.stock.service.IBoardIndexDaily;
import com.analyse.stock.service.IPickStockAnalyse;
import com.analyse.stock.vo.PickStockVO;
import com.analyse.stock.vo.ResultUtils;
import com.analyse.stock.vo.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/pick")
public class PickStockAnalyseController {

    @Autowired
    private IPickStockAnalyse pickStockAnalyse;

    @Autowired
    private IBoardIndexDaily boardIndexDaily;

    /***
      * 获取某个股票代码资金历史流向
     */
    @PostMapping("/stock")
    public ResultVo<List<PickStockVO>> pickStock(@RequestBody PickStockQueryForm queryForm) {
        return ResultUtils.ok(pickStockAnalyse.pickStock(queryForm));
    }

    /***
     * 通过各种技术指标综合分析
     */
    @PostMapping("/stock/detect")
    public ResultVo<List<PickStockVO>> detect(@RequestBody PickStockQueryForm queryForm) {
        return ResultUtils.ok(pickStockAnalyse.detect(queryForm));
    }

    /***
     * 分析大盘指数情绪
     */
    @GetMapping("/index/sentiment")
    public ResultVo<String> sentimentAnalyzer(@RequestParam(name = "code") String indexCode) {
        Sentiment sentiment = boardIndexDaily.sentimentAnalyzer(indexCode,1);
        return ResultUtils.ok(sentiment.getDesc());
    }
}
